        integer function scrdmp
* This subroutine prints the current screen image to the imagewritter printer.
* This is equivalent to entering a caps lock-command-shift-4 from the keyboard.
* It must be called with an empty parameter list, so that the
* compiler can distinguish it from a simple variable:
*
*       error = scrdmp()
*
* 12 Mar 86	Sent to Compuserve.				EWG

        implicit none
        integer toolbx

        include file.inc
        include misc.inc
        include params.inc

* Constant print driver reference number.
        integer iprdrvrref
        parameter (iprdrvrref = -3)

* Eqivalence a 3 words (integer*2) over the first 6 elements of the byte array
* csparam (in params.inc) for convenience in setting up the printer port.
        integer*2 prcont(3)             ! Print protocol control words.
        equivalence (csparam(1),prcont(1))

        character*7 filename            ! Used to build print driver name.

        integer err                     ! Error code for file calls.
        integer i                       ! scratch

        integer paramptr                ! Pointer to the parameter block.

* Clear the file parameter block.
        do (i = 1, 80)
          params(i) = 0
        repeat

        paramptr = toolbx(PTR, params)  ! Pointer to parameter block.

* Open the printer port for output.
        filename = char(6) // '.PRINT'
        ionameptr = toolbx(PTR, filename)
        err = toolbx(PBOPEN, paramptr)
        if (err <> 0) goto 100

* Reset the printer.
        cscode = 7
        prcont(1) = 1
        prcont(2) = 0
        err = toolbx(PBCONTROL, paramptr)
        if (err <> 0) goto 100

* Print the screen.
        cscode = 6
        prcont(1) = 2
        prcont(2) = 0                   ! Default - use 1 for square pixels.
        err = toolbx(PBCONTROL, paramptr)
        if (err <> 0) goto 100

* Close the printer port.
        err = toolbx(PBCLOSE, paramptr)

  100   scrdmp = err

        return
        end
